package com.bm.web.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bm.entity.onenNew;
import com.bm.service.ImgService;
import com.bm.service.impl.ImgServiceImpl;

/**
 * Servlet implementation class twonewServlet
 */
@WebServlet("/twonewServlet")
public class twonewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public twonewServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		HttpSession session = request.getSession();
		ImgService imgservice = new ImgServiceImpl();
		String id = request.getParameter("newid");
		
		List<onenNew> list = imgservice.twoNewList(id);
			
		session.setAttribute("title", list.get(0).getNewTitle());
		session.setAttribute("word", list.get(0).getNewWord());
		session.setAttribute("next_Word", list.get(0).getNewsContent());
		request.getRequestDispatcher("new-word.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
